from tortoise import fields
from datetime import datetime
from .base import BaseModel, TimestampMixin


class SysDept(BaseModel, TimestampMixin):
    """部门表"""

    dept_id = fields.IntField(pk=True, description="部门id")

    parent_id = fields.IntField(null=True, description="父部门id")

    ancestors = fields.CharField(max_length=50, null=True, description="祖级列表")

    dept_name = fields.CharField(max_length=30, null=True, description="部门名称")

    order_num = fields.IntField(null=True, description="显示顺序")

    leader = fields.CharField(max_length=20, null=True, description="负责人")

    phone = fields.CharField(max_length=11, null=True, description="联系电话")

    email = fields.CharField(max_length=50, null=True, description="邮箱")

    status = fields.CharField(max_length=1, null=True, description="状态（0代表存在 2代表删除）")

    use_flag = fields.CharField(max_length=1, null=True, description="部门状态（0正常 1停用）")

    create_by = fields.CharField(max_length=64, null=True, description="创建者")

    create_time = fields.DatetimeField(null=True, description="创建时间")

    update_by = fields.CharField(max_length=64, null=True, description="更新者")

    update_time = fields.DatetimeField(null=True, description="更新时间")

    class Meta:
        table = "sys_dept"

    def __str__(self):
        return f"{self.dept_id}"